package concepts.heap;

import java.util.ArrayList;
import java.util.List;

public class HeapSizeExampleRunner {

	public static void main(String[] args) {
		
		long start = getHeapSize();
		System.out.println("start-" + start);
		
		createObjects(100);
		
		long finish = getHeapSize();
		System.out.println("finish-" + finish);
		
		System.out.println("Result - " + (finish - start));
		
		
	}
	
	private static void createObjects(int count)
	{
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < count; i++) {
			list.add(String.valueOf(i));
		}
	}
	
	private static long getHeapSize()
	{
		return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
	}
	
}
